<?php

class Storage_Pathtype_Simple
{

	public function generate($params)
	{
		$params = (array)$params;

		extract($params);

		if (!isset($parent_id) or !$parent_id)
		{
			$parent_id = mt_rand(0, 0xFFFFFFF);
		}

		if (!isset($file_id) or !$file_id)
		{
			$file_id = mt_rand(0, 0xFFFFFFF);
		}

		if (!isset($extension) or !$extension)
		{
			$extension = 'jpg';
		}

		$subdir = ((int)$parent_id + 999 - (((int)$parent_id - 1) % 1000));

		return 'public' . '/' . $subdir . '/' . $parent_id . '/' . $file_id . '.' . strtolower($extension);
	}

}
